#include<vector>
#include "common/rc.h"
#include "sql/stmt/stmt.h"
class FilterStmt;
class Table;
class Db;
class JoinUnit{
public:
JoinUnit() = default;
~JoinUnit(){
    if(filter_stmt_!=nullptr){
       delete filter_stmt_;
       filter_stmt_=nullptr;
    }
}
JoinUnit(const JoinUnit& other);
JoinUnit& operator=(const JoinUnit& other);
void set_table_name(const char* table_name){
    table_name_=table_name;
}
void set_filter_stmt(FilterStmt* filter_stmt){
 filter_stmt_=filter_stmt;
}
const char* table_name(){
    return table_name_.c_str();
};
FilterStmt* filter_stmt(){
    return filter_stmt_;
}
private:
    std::string table_name_;
    FilterStmt* filter_stmt_=nullptr;
};
class JoinStmt{
    std::vector<JoinUnit*> join_units_;
    public:
   JoinStmt() = default;
   JoinStmt(const JoinStmt& other);
   JoinStmt& operator=(const JoinStmt& other);
    virtual ~JoinStmt();
    static RC create(Db* db,const JoinAttrSqlNode* joins,int join_num ,JoinStmt *&stmt);
 std::vector<JoinUnit*> join_units() 
  {
    return join_units_;
  }
};